import 'package:flutter/material.dart';
import 'package:flutter_getx/app/routes/app_pages.dart';
import 'package:get/get.dart';

import '../controllers/login_controller.dart';

class LoginView extends GetView<LoginController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('登录'),
        centerTitle: true,
      ),
      body: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(
              height: Get.height * .3,
              padding: EdgeInsets.only(left: 50, right: 50),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  TextField(
                    controller: controller.accountTec,
                    keyboardType: TextInputType.number,
                    autofocus: true,
                    decoration: InputDecoration(
                        border: OutlineInputBorder(),
                        contentPadding: EdgeInsets.all(10.0),
                        prefixIcon: Icon(Icons.phone),
                        hintText: '请输入账号',
                        labelText: '手机号'),
                  ),
                  TextField(
                      controller: controller.pwdTec,
                      keyboardType: TextInputType.number,
                      decoration: InputDecoration(
                          border: OutlineInputBorder(),
                          contentPadding: EdgeInsets.all(10.0),
                          prefixIcon: Icon(Icons.key),
                          hintText: '请输入密码',
                          labelText: '密码'),
                      obscureText: true),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: [
                      GestureDetector(
                        onTap: () {
                          Get.toNamed(Routes.SIGN_UP);
                        },
                        child: Padding(
                          padding: const EdgeInsets.all(10.0),
                          child: Text("没账号, 去注册",style: TextStyle(color: Colors.blue),),
                        ),
                      )
                    ],
                  )
                ],
              ),
            ),
            Container(
              width: Get.width * 0.7,
              height: Get.height * .07,
              child: ElevatedButton.icon(
                icon: Icon(Icons.send),
                label: Text('登录'),
                onPressed: () {
                  controller.login();
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}
